<script setup lang='ts'>
  import { onMounted, reactive } from 'vue';
  import { numberApi } from '@/api/controller';
  import { Toastloading } from '@/utils/public';
  import { getPlayEndTime, getDateArray } from '@/utils'
  import Pagination from "@/components/Pagination/index.vue";
  import serachUserid from '@/components/serachUserid/index.vue';
  import xmDatePicker from '@/components/xmDatePicker/index.vue';
  const action = reactive({
    total:0,
    list:[] as any[],
    EquipType:[] as any[],
    dateArr:[],
    timeObj:getPlayEndTime(getDateArray('ymdhis'))
  })
  const initialQuery = {
    from_user_id:'',
    user_id:'',
    page: 1,
    limit: 20,
  }
  const listQuery = reactive({
    ...initialQuery
  })
  const handleFilter = ()=>{
    listQuery.page = 1
    getList()
  }
  const resetQuery = ()=>{
    Object.assign(listQuery,{
      ...initialQuery
    })
    action.timeObj = getPlayEndTime(getDateArray('ymdhis'))
    getList()
  }
  const getList = async()=> {
    const loading = Toastloading()
    const { playTime:time_st, endTime:time_ed } = action.timeObj
    const res = await numberApi.agentDiamondLogList({
      ...listQuery,
      time_st,
      time_ed,
    })
    loading.close()
    const { data=[], total=0 } = res.data
    action.list = data
    action.total = total
  }
  onMounted(()=>{
    getList()
  })
</script>

<template>
  <div class="xm-content">
    <div class="xm-headTab">
      <div class="labelBox">
        <div class="labelItem">
          <div class="label">接收用户ID：</div>
          <serachUserid v-model:user_id="listQuery.user_id" />
        </div>
        <div class="labelItem">
          <div class="label">赠送用户ID：</div>
          <serachUserid v-model:user_id="listQuery.from_user_id" />
        </div>
        <xmDatePicker v-model:timeval="action.timeObj" />
        <div class="labelItem">
          <el-button type="primary" @click="handleFilter">查询</el-button>
          <el-button type="primary" @click="resetQuery">重置</el-button>
        </div>
      </div>
    </div>
    <el-table
      class="xm-main xm-TableCenter"
      :data="action.list"
      border>
      <el-table-column width="120" prop="id" label="记录ID" />
      <el-table-column label="接收用户">
        <el-table-column min-width="120" prop="user_id" label="用户ID" />
        <el-table-column min-width="120" prop="uuid" label="用户UUID" />
        <el-table-column min-width="120" prop="nickname" label="用户昵称" />
      </el-table-column>
      <el-table-column label="赠送用户">
        <el-table-column min-width="120" prop="from_user_id" label="用户ID" />
        <el-table-column min-width="120" prop="from_uuid" label="用户UUID" />
        <el-table-column min-width="120" prop="from_nickname" label="用户昵称" />
      </el-table-column>
      <el-table-column min-width="120" prop="diamond_num" label="钻石红包金额" />
      <el-table-column min-width="120" prop="agentd_type" label="领取状态">
        <template #default="scope">
          {{ ['','未领取','主动领取','自动领取'][scope.row.agentd_type] }}
        </template>
      </el-table-column>
      <el-table-column min-width="120" prop="created_at" label="时间" />
    </el-table>
    <Pagination v-show="action.total > 0" :total="action.total" v-model:page="listQuery.page"
      v-model:limit="listQuery.limit" @pagination="getList" />
  </div>
</template>
